\(\int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx\) [230]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 26, antiderivative size = 33 \[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=-\frac {a \cos ^3(c+d x)}{3 d}+\frac {b \sin ^2(c+d x)}{2 d} \]

[Out]

-1/3*a*cos(d*x+c)^3/d+1/2*b*sin(d*x+c)^2/d

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 33, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.192, Rules used = {4462, 12, 2644, 30, 2645} \[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=\frac {b \sin ^2(c+d x)}{2 d}-\frac {a \cos ^3(c+d x)}{3 d} \]

[In]

Int[Cos[c + d*x]^2*(a*Sin[c + d*x] + b*Tan[c + d*x]),x]

[Out]

-1/3*(a*Cos[c + d*x]^3)/d + (b*Sin[c + d*x]^2)/(2*d)

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2644

Int[cos[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sin[(e_.) + (f_.)*(x_)])^(m_.), x_Symbol] :> Dist[1/(a*f), Subst[Int[
x^m*(1 - x^2/a^2)^((n - 1)/2), x], x, a*Sin[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2] &&
 !(IntegerQ[(m - 1)/2] && LtQ[0, m, n])

Rule 2645

Int[(cos[(e_.) + (f_.)*(x_)]*(a_.))^(m_.)*sin[(e_.) + (f_.)*(x_)]^(n_.), x_Symbol] :> Dist[-(a*f)^(-1), Subst[
Int[x^m*(1 - x^2/a^2)^((n - 1)/2), x], x, a*Cos[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2]
 &&  !(IntegerQ[(m - 1)/2] && GtQ[m, 0] && LeQ[m, n])

Rule 4462

Int[(u_)*((v_) + (d_.)*(F_)[(c_.)*((a_.) + (b_.)*(x_))]^(n_.)), x_Symbol] :> With[{e = FreeFactors[Cos[c*(a +
b*x)], x]}, Int[ActivateTrig[u*v], x] + Dist[d, Int[ActivateTrig[u]*Sin[c*(a + b*x)]^n, x], x] /; FunctionOfQ[
Cos[c*(a + b*x)]/e, u, x]] /; FreeQ[{a, b, c, d}, x] &&  !FreeQ[v, x] && IntegerQ[(n - 1)/2] && NonsumQ[u] &&
(EqQ[F, Sin] || EqQ[F, sin])

Rubi steps \begin{align*} \text {integral}& = a \int \cos ^2(c+d x) \sin (c+d x) \, dx+\int b \cos (c+d x) \sin (c+d x) \, dx \\ & = b \int \cos (c+d x) \sin (c+d x) \, dx-\frac {a \text {Subst}\left (\int x^2 \, dx,x,\cos (c+d x)\right )}{d} \\ & = -\frac {a \cos ^3(c+d x)}{3 d}+\frac {b \text {Subst}(\int x \, dx,x,\sin (c+d x))}{d} \\ & = -\frac {a \cos ^3(c+d x)}{3 d}+\frac {b \sin ^2(c+d x)}{2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.16 (sec) , antiderivative size = 38, normalized size of antiderivative = 1.15 \[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=-\frac {3 a \cos (c+d x)+3 b \cos (2 (c+d x))+a \cos (3 (c+d x))}{12 d} \]

[In]

Integrate[Cos[c + d*x]^2*(a*Sin[c + d*x] + b*Tan[c + d*x]),x]

[Out]

-1/12*(3*a*Cos[c + d*x] + 3*b*Cos[2*(c + d*x)] + a*Cos[3*(c + d*x)])/d

Maple [A] (verified)

Time = 0.94 (sec) , antiderivative size = 29, normalized size of antiderivative = 0.88

method result size
derivativedivides \(-\frac {\frac {\cos \left (d x +c \right )^{3} a}{3}+\frac {\cos \left (d x +c \right )^{2} b}{2}}{d}\) \(29\)
default \(-\frac {\frac {\cos \left (d x +c \right )^{3} a}{3}+\frac {\cos \left (d x +c \right )^{2} b}{2}}{d}\) \(29\)
risch \(-\frac {a \cos \left (d x +c \right )}{4 d}-\frac {a \cos \left (3 d x +3 c \right )}{12 d}-\frac {b \cos \left (2 d x +2 c \right )}{4 d}\) \(44\)

[In]

int(cos(d*x+c)^2*(sin(d*x+c)*a+b*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

-1/d*(1/3*cos(d*x+c)^3*a+1/2*cos(d*x+c)^2*b)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 28, normalized size of antiderivative = 0.85 \[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=-\frac {2 \, a \cos \left (d x + c\right )^{3} + 3 \, b \cos \left (d x + c\right )^{2}}{6 \, d} \]

[In]

integrate(cos(d*x+c)^2*(a*sin(d*x+c)+b*tan(d*x+c)),x, algorithm="fricas")

[Out]

-1/6*(2*a*cos(d*x + c)^3 + 3*b*cos(d*x + c)^2)/d

Sympy [F]

\[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=\int \left (a \sin {\left (c + d x \right )} + b \tan {\left (c + d x \right )}\right ) \cos ^{2}{\left (c + d x \right )}\, dx \]

[In]

integrate(cos(d*x+c)**2*(a*sin(d*x+c)+b*tan(d*x+c)),x)

[Out]

Integral((a*sin(c + d*x) + b*tan(c + d*x))*cos(c + d*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.23 (sec) , antiderivative size = 28, normalized size of antiderivative = 0.85 \[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=-\frac {2 \, a \cos \left (d x + c\right )^{3} - 3 \, b \sin \left (d x + c\right )^{2}}{6 \, d} \]

[In]

integrate(cos(d*x+c)^2*(a*sin(d*x+c)+b*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/6*(2*a*cos(d*x + c)^3 - 3*b*sin(d*x + c)^2)/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 99 vs. \(2 (29) = 58\).

Time = 0.36 (sec) , antiderivative size = 99, normalized size of antiderivative = 3.00 \[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=-\frac {a \cos \left (3 \, d x + 3 \, c\right )}{12 \, d} - \frac {a \cos \left (d x + c\right )}{4 \, d} - \frac {b \tan \left (d x\right )^{2} \tan \left (c\right )^{2} - b \tan \left (d x\right )^{2} - 4 \, b \tan \left (d x\right ) \tan \left (c\right ) - b \tan \left (c\right )^{2} + b}{4 \, {\left (d \tan \left (d x\right )^{2} \tan \left (c\right )^{2} + d \tan \left (d x\right )^{2} + d \tan \left (c\right )^{2} + d\right )}} \]

[In]

integrate(cos(d*x+c)^2*(a*sin(d*x+c)+b*tan(d*x+c)),x, algorithm="giac")

[Out]

-1/12*a*cos(3*d*x + 3*c)/d - 1/4*a*cos(d*x + c)/d - 1/4*(b*tan(d*x)^2*tan(c)^2 - b*tan(d*x)^2 - 4*b*tan(d*x)*t
an(c) - b*tan(c)^2 + b)/(d*tan(d*x)^2*tan(c)^2 + d*tan(d*x)^2 + d*tan(c)^2 + d)

Mupad [B] (verification not implemented)

Time = 22.96 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.48 \[ \int \cos ^2(c+d x) (a \sin (c+d x)+b \tan (c+d x)) \, dx=-\frac {\left (\cos \left (c+d\,x\right )+1\right )\,\left (2\,a-3\,b-2\,a\,\cos \left (c+d\,x\right )+3\,b\,\cos \left (c+d\,x\right )+2\,a\,{\cos \left (c+d\,x\right )}^2\right )}{6\,d} \]

[In]

int(cos(c + d*x)^2*(a*sin(c + d*x) + b*tan(c + d*x)),x)

[Out]

-((cos(c + d*x) + 1)*(2*a - 3*b - 2*a*cos(c + d*x) + 3*b*cos(c + d*x) + 2*a*cos(c + d*x)^2))/(6*d)